<template>
	<view class="container">
		<uni-section title="食品轮播图展示" sub-title="" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="item in swiperlist">
				<image :src="'http://localhost:8090'+item.icon" mode="" style="width: 100%;height: 300rpx;"></image>
				</swiper-item>
			</swiper>
		</uni-section>
		<uni-section title="食物类别宫格展示" sub-title="" type="line">
					<uni-grid :column="3">
						<uni-grid-item v-for="item in foodtypelist">
							<view style="width: 100%; height: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;">
								<image :src="'http://localhost:8090/'+item.icon" mode="" style="width:140rpx; height:140rpx;">
								</image>
								<view>{{item.typename}}</view>
							</view>
						</uni-grid-item>
					</uni-grid>
				</uni-section>
		<uni-section :title="'食品列表展示('+foodlist.length+'条)'" sub-title="" type="line">
			<uni-list>
				<uni-list-item :to="'../fooddetail/fooddetail?id='+item.id" :title="item.name" note="" :thumb="'http://localhost:8090'+item.icon" :rightText=" +item.price+'元'" v-for="item in foodlist"></uni-list-item>
			</uni-list>
		</uni-section>
		<uni-section :title="'食品评论列表展示('+commentlist.length+'条)'" sub-title="" type="line">
			<uni-list>
				<uni-list-item :title="item.comment"  :rightText="item.postdate" v-for="item in commentlist"></uni-list-item>
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				foodlist:[],
				commentlist:[],
				swiperlist:[],
				foodtypelist:[]
			}
		},
		methods: {

		},
		onLoad(){
			uni.request({
				url: 'http://localhost:8090/foodapp/foodSwiper/list',
				method: 'POST',
				success: res => {
					if(res.data.success){
						this.swiperlist=res.data.list
					}
				}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/food/list',
				method: 'POST',
				success: res => {
					if(res.data.success){	
						this.foodlist=res.data.list					
					}
				}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/foodType/list',
				method: 'POST',
				success: res => {
					if(res.data.success){
						this.foodtypelist=res.data.list
					}
				}
			});
			
		},
		onShow() {
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'POST',
				success: res => {
					if(res.data.success){
						this.commentlist=res.data.list
					}
				}
			});
		}
	}
</script>

<style>

</style>